/*
*    Phantom v2.0 GUI Automation Software
*    Copyright (C) 2009  John C. Van Arsdall (john@phantomtest.com)
*
*    This program is free software; you can redistribute it and/or modify
*    it under the terms of the GNU General Public License as published by
*    the Free Software Foundation; either version 2 of the License, or
*    (at your option) any later version.
*
*    This program is distributed in the hope that it will be useful,
*    but WITHOUT ANY WARRANTY; without even the implied warranty of
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*    GNU General Public License for more details.
*
*    You should have received a copy of the GNU General Public License along
*    with this program; if not, write to the Free Software Foundation, Inc.,
*    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
*/
#pragma once

#include "ssi_status.h"
#include "ssi_string.h"
#include "ssi_variable.h"
//#include "ssi_tnode.h"

//This modification made on 4/1/2008
//#define USE_MY_LISTS

#include <deque>
#include <list>
#include <iterator>
using std::deque;
using std::list;
using std::iterator;

#define COMPONENT_STATEMENT 1
#define COMPONENT_TOKEN     2
#define COMPONENT_VARIABLE  3

//typedef struct{
//  String Component;
//  SSI_INT64 Type;
//	VarTree Vars;
//}ScriptComponentT;

class ScriptComponentT
{
public:
	ScriptComponentT();
	ScriptComponentT(const ScriptComponentT& Other);
	SSI_BOOL pop(CVariable& Var);
	~ScriptComponentT();
  String Component;
  SSI_INT64 Type;
	VarTree Vars;
};


//typedef deque<ScriptComponentT> ComponentTree;
//typedef deque<ScriptComponentT>::iterator ComponentItor;


#ifdef USE_MY_LISTS
  typedef TNodeTree<ScriptComponentT> ComponentTree;
  typedef TNode<ScriptComponentT> ComponentItor;
#else
  typedef list<ScriptComponentT> ComponentTree;
  typedef list<ScriptComponentT>::iterator ComponentItor;
#endif

class CComponentParser
{
public:
	CComponentParser(void);
	virtual ~CComponentParser(void);
	CStatus ParseLine(const String& InLine);
	ComponentTree m_List;

	ComponentItor GetTop(void);
	ComponentItor GetNextNode(ComponentItor In);
	//ComponentNode* GetNextNode(ComponentNode* In);
	//ComponentNode* GetTop(void);
	//CStatus DeleteNodeRange(ComponentNode* StartNode, ComponentNode* EndNode);
	CStatus DeleteNodeRange(ComponentItor StartNode, ComponentItor EndNode);
  CStatus InsertAfter(ComponentItor Before, ScriptComponentT& New);

	//CStatus InsertAfter(ComponentNode* Before, ScriptComponentT& New);
	ComponentItor CurrItor;
  ComponentItor GetCurrItor(void);
  ComponentItor SetCurrItor(ComponentItor Itor);
 
	ComponentItor end();
	ComponentItor begin();
	ComponentItor next(ComponentItor Curr);
	ComponentItor prev(ComponentItor Curr);
  void push(ScriptComponentT& New);

	ComponentItor GetLeft(ComponentItor In);
	ComponentItor GetRight(ComponentItor In);



	//ComponentNode* CurrPtr;
	//ComponentNode* GetCurrPtr(void);
	//ComponentNode* SetCurrPtr(ComponentNode* Ptr);
	//ComponentNode* GetLeft(ComponentNode* In);
	//ComponentNode* GetRight(ComponentNode* In);
};



